/**
 * @author Roderick Cusirramos Montesinos
 * @version 0.1
 */

package solucionessgh.View;

import java.io.InputStream;
import java.util.Properties;

public class ModelProject {
    private static ModelProject instance;
    private Properties propiedades ;

    public ModelProject(){
        propiedades = new Properties();
        String ruta = "/solucionessgh/resources/config.properties";
        propiedades = carga(ruta);
    }

    //Funciones para el singleton
    static public ModelProject Instance() {
        if (instance == null) {
            instance = new ModelProject();
            return instance;
        } else
            return instance;
    }
    public void finalize() {
        instance = null;
    }
    //--------------------------------------------------------------------------
    public Properties carga(String ruta){
        try {
            InputStream is = getClass().getResourceAsStream(ruta);
            if (is != null) {
                try {
                    Properties props = new Properties();
                    props.load(is);
                    return props;
                }catch(Exception ex){
                    System.err.println(ex.toString());
                }
            }else{
                System.err.println("No se encontro fichero");
            }
        }catch(Exception ex){
            System.err.println(ex.toString());
        }
        return null;
    }
    public String getName(String key){
        return propiedades.getProperty(key);
    }
    //--------------------------------------------------------------------------
    
   
}
